home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 1
/
Deutsche Edition 1.iso
/
amok
/
071-080
/
amok73
/
ums
/
demos&utils
/
source
/
selectmail.mod
< prev
Wrap
Text File
|
1993-11-04
|
5KB
|
162 lines
MODULE SelectMail;
IMPORT ums, uc:umsConsts, MHArgs, io, u:Utility, sys:SYSTEM, NoGuru;
VAR
login : LONGINT;
cfg : MHArgs.Config;
name,pwd,sname: ARRAY 256 OF CHAR;
result : LONGINT;
PROCEDURE CheckErr();
VAR err: INTEGER; txt:ums.STRPTR;
BEGIN
err := ums.ErrNum( login );
IF err # uc.ok THEN
io.WriteString("UMS-error:");
io.WriteInt( err, 3);
io.WriteString(", '");
txt := ums.ErrTxt( login );
io.WriteString(txt^);
io.WriteString("'\n");
HALT(20);
END;
END CheckErr;
BEGIN
cfg := MHArgs.OpenConfig( "NAME/A,PASSWORD/A,SELECT-NAME","Select Mail - © 15.4.1992 by Martin Horneffer\n\
Select messages addressed to a certain user.\n\n\
name, password : your name and password for UMS.\n\
select-name : select all messages that are addressed to this user.\n\
This is done by the 'to'-field as well as by threads.\n\
Default is same as 'name'\n", NIL);
IF cfg = NIL THEN HALT(20) END;
IF cfg.GetString( "NAME", name) & cfg.GetString( "PASSWORD", pwd) THEN
IF ~cfg.GetString( "SELECT-NAME", sname) THEN sname := name END;
login := ums.Login( name, pwd);
IF login = 0 THEN
io.WriteString("login failure\n");
ELSE
(* NOTE: since we just logged in all local flags are cleared. *)
(* Usually you'll have to clear them by hand before using. *)
(* set local flag 0 on all new messages *)
io.WriteString("looking for new messages: ");
result := ums.UMSSelectTags( login,
u.user + uc.tagSelMask, LONGSET{uc.ViewAccess,uc.postPoned,uc.Old},
u.user + uc.tagSelMatch, LONGSET{uc.ViewAccess},
u.user + uc.tagSelWriteLocal, 1,
u.user + uc.tagSelSet, LONGSET{0},
u.user + uc.tagSelUnset, LONGSET{},
u.done);
io.WriteInt( result, 1); io.WriteString(" found.\n");
CheckErr();
(* set local flag 1 on all messages with matching TONAME *)
io.WriteString("selecting by name: ");
result := ums.UMSSelectTags( login,
u.user + uc.tagToName, sys.ADR(sname),
u.user + uc.tagSelWriteLocal, 1,
u.user + uc.tagSelSet, LONGSET{1},
u.user + uc.tagSelUnset, LONGSET{},
u.user + uc.tagSelQuick, 1,
u.done);
io.WriteInt( result, 1); io.WriteString(" selected.\n");
CheckErr();
(* set local flag 4 for the new ones amongst them *)
io.WriteString(" new messages amongst these: ");
result := ums.UMSSelectTags( login,
u.user + uc.tagSelReadLocal, 1,
u.user + uc.tagSelMask, LONGSET{0,1},
u.user + uc.tagSelMatch, LONGSET{0,1},
u.user + uc.tagSelWriteLocal, 1,
u.user + uc.tagSelSet, LONGSET{4},
u.user + uc.tagSelUnset, LONGSET{},
u.user + uc.tagSelQuick, 1,
u.done);
io.WriteInt( result, 1); io.WriteString(".\n");
CheckErr();
(* set local flag 2 on all messages with matching FROMNAME *)
io.WriteString("looking for messages written by you: ");
result := ums.UMSSelectTags( login,
u.user + uc.tagFromName, sys.ADR(sname),
u.user + uc.tagSelWriteLocal, 1,
u.user + uc.tagSelSet, LONGSET{2},
u.user + uc.tagSelUnset, LONGSET{},
u.user + uc.tagSelQuick, 1,
u.done);
io.WriteInt( result, 1); io.WriteString(" found.\n");
CheckErr();
(* set local flag 3 on all replies to messages with flag 2 *)
io.WriteString("selecting replies to your msgs: ");
result := ums.UMSSelectTags( login,
u.user + uc.tagSelReadLocal, 1,
u.user + uc.tagSelParent, 1,
u.user + uc.tagSelMask, LONGSET{2},
u.user + uc.tagSelMatch, LONGSET{2},
u.user + uc.tagSelWriteLocal, 1,
u.user + uc.tagSelSet, LONGSET{3},
u.user + uc.tagSelUnset, LONGSET{},
u.user + uc.tagSelQuick, 1,
u.done);
io.WriteInt( result, 1); io.WriteString(" selected.\n");
CheckErr();
(* set local flag 4 for the new ones amongst them *)
io.WriteString(" new messages amongst these: ");
result := ums.UMSSelectTags( login,
u.user + uc.tagSelReadLocal, 1,
u.user + uc.tagSelMask, LONGSET{0,3},
u.user + uc.tagSelMatch, LONGSET{0,3},
u.user + uc.tagSelWriteLocal, 1,
u.user + uc.tagSelSet, LONGSET{4},
u.user + uc.tagSelUnset, LONGSET{},
u.user + uc.tagSelQuick, 1,
u.done);
io.WriteInt( result, 1); io.WriteString(".\n");
CheckErr();
(* set user-flag 7 on all messages with local flag 4 set *)
io.WriteString("totally selected: ");
result := ums.UMSSelectTags( login,
u.user + uc.tagSelReadLocal, 1,
u.user + uc.tagSelMask, LONGSET{4},
u.user + uc.tagSelMatch, LONGSET{4},
u.user + uc.tagSelSet, LONGSET{uc.selected},
u.user + uc.tagSelUnset, LONGSET{},
u.done);
io.WriteInt( result, 1); io.WriteString(".\n");
CheckErr();
END;
END;
CLOSE
IF login # 0 THEN ums.Logout(login) END;
END SelectMail.